﻿using CBApp.DataModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.Entity.Migrations;

namespace CBApp.Db
{
    public static class Seeder
    {
        public static void Seed(
            ApplicationDbContext db,
            bool seedComicBooks = true,
            bool seedCharacters = true,
            bool seedArtists = true,
            bool seedArtistsComicBook = true
            )
        {
            if (seedComicBooks)
            {
                db.ComicBooks.AddOrUpdate(p => p.Title,
                    new ComicBook { Title = "Uncanny X-Men", Image = "http://3.bp.blogspot.com/-6sjmoRxSf8U/TgJFgLoLcSI/AAAAAAAADoA/vXIUGG8_o94/s1600/mutantgenesis.jpg" },
                    new ComicBook { Title = "Captain America", Image = "http://pressstart2begin.files.wordpress.com/2013/05/858650_269970406469880_1615169337_o.jpg" },
                    new ComicBook { Title = "Superman", Image = "http://images.monstermarketplace.com/kids-bedding-sets-and-diaper-bags/comic-book-cover-superman-kryptonite-comic-cover-900x1350.jpg" },
                    new ComicBook { Title = "The Amazing Spiderman", Image = "http://31.media.tumblr.com/tumblr_m43akkwX1W1qbgo38o1_1280.jpg" },
                    new ComicBook { Title = "Fantastic Four", Image = "http://biblicon.org/wp-content/uploads/2011/01/fantastic_four_82.jpg" },
                    new ComicBook { Title = "Iron Man", Image ="http://www.michelravey.com/wp-content/uploads/2012/09/2004.03-IronMan76-AdiGranov.jpg"},
                    new ComicBook { Title = "Batman", Image = "http://media.comicbook.com/wp-content/uploads/2013/02/detective-comics-18.jpg" },
                    new ComicBook { Title = "Thor", Image = "https://spencerd.files.wordpress.com/2010/04/thor177.jpg" },
                    new ComicBook { Title = "Guardians of the Galaxy", Image = "http://media.comicbook.com/wp-content/uploads/2012/10/iron-man-guardians-of-the-galaxy.jpg" },
                    new ComicBook { Title = "Hawkeye", Image="http://ifanboy.com/wp-content/uploads/2012/10/Hawkeye_3.jpg"},
                    new ComicBook {Title = "Gambit", Image="http://www.blueravencomics.com/wp-content/uploads/2013/02/GAMBIT-9-Cover.jpg"}


                    );
                db.SaveChanges();
            }
            if (seedCharacters)
            {
                db.Characters.AddOrUpdate(p => p.Name,
                new Character { Name = "Superman", Image= "http://static.comicvine.com/uploads/original/11111/111113523/3605753-1936874063-31646.png", ComicBookId=3},
                new Character { Name = "Spiderman", Image= "http://imageserver.moviepilot.com/2236476-gsm_169_marvelheroes_spiderman_090613_320-spider-man-to-join-the-avengers-big-announcement-coming.jpeg?width=1272&height=714", ComicBookId=4},
                new Character { Name = "Gambit", Image = "http://img3.wikia.nocookie.net/__cb20130209184651/avengersalliance/images/3/34/Gambit_Portrait_Art.png", ComicBookId=11 },
                new Character { Name = "Batman", Image = "http://static.comicvine.com/uploads/scale_medium/11111/111112549/3115207-9065105869-NealA.jpg", ComicBookId=7},
                new Character { Name = "X-Men", Image ="http://www.mylatestdistraction.com/mylatestdistraction/wp-content/uploads/2010/07/X-Men-JimLee-Poster-Tribute08.jpg", ComicBookId=1},
                new Character { Name = "Wolverine", Image = "http://fc07.deviantart.net/fs71/f/2012/230/1/e/wolverine_colored_by_sjsegovia-d5bjgbk.png", ComicBookId=1},
                new Character { Name = "Cyclops", Image ="http://th01.deviantart.net/fs71/PRE/f/2012/118/2/0/cyclops__by_arfel1989-d4xte1g.jpg", ComicBookId=1},
                new Character { Name = "Thor", Image = "http://static.comicvine.com/uploads/original/11/117763/2786642-tumblr_mg2iesn3go1qiknbco1_1280.jpg",ComicBookId=8},
                new Character { Name = "Hawkeye", Image = "http://static.comicvine.com/uploads/original/6/69951/3095102-hawkeye.png", ComicBookId=10},
                new Character { Name = "Ironman", Image = "http://img1.wikia.nocookie.net/__cb20130904210747/disney/images/4/4c/SJPA_Iron_Man_1.png", ComicBookId=6},
                new Character { Name = "Human Torch", Image = "http://veryaware.com/wp-content/uploads/2013/05/Storm.jpg", ComicBookId=5},
                new Character { Name = "Captain America", Image = "http://static.comicvine.com/uploads/original/11114/111141062/4012841-captain+america.jpg", ComicBookId=2},
                new Character { Name = "Starlord", Image = "http://img2.wikia.nocookie.net/__cb20140625043807/disney/images/9/95/Star-Lord_Promo_Art_Decor_III.png", ComicBookId=9}
           );

                db.SaveChanges();
            }
            if (seedArtists)
            {
                db.Artists.AddOrUpdate(p=>p.Name,

                    new Artist { Name = "Jim Lee", Image = "http://upload.wikimedia.org/wikipedia/commons/2/2f/Jim_Lee_by_Gage_Skidmore.jpg" },
                    new Artist { Name = "Rob Liefield", Image = "http://upload.wikimedia.org/wikipedia/commons/d/db/Rob_Liefeld,_Amazing_Arizona_Comic_Con,_2014.jpg" },
                    new Artist { Name = "John Romita Jr", Image = "http://media.creativebloq.futurecdn.net/sites/creativebloq.com/files/images/2012/07/johnromita(1).jpg" },
                    new Artist { Name = "Brian Bolland", Image = "http://media.creativebloq.futurecdn.net/sites/creativebloq.com/files/images/2012/07/brian.jpg" },
                    new Artist { Name = "Jim Steranko", Image = "http://media.creativebloq.futurecdn.net/sites/creativebloq.com/files/images/2012/07/jims.jpg" },
                    new Artist { Name = "Steve Ditko", Image = "http://media.creativebloq.futurecdn.net/sites/creativebloq.com/files/images/2012/07/sitko.jpg" },
                    new Artist { Name = "Frank Miller", Image = "http://media.creativebloq.futurecdn.net/sites/creativebloq.com/files/images/2012/07/frankiemiller.jpg" },
                    new Artist { Name = "Jack Kirby", Image = "http://media.creativebloq.futurecdn.net/sites/creativebloq.com/files/images/2012/07/kirby(1).jpg" },
                    new Artist { Name = "Alex Ross", Image = "https://pbs.twimg.com/profile_images/1877278395/office_2.jpg" }

                    );
                db.SaveChanges();
            }
            if (seedArtistsComicBook)
            {
                db.ArtistComicBooks.AddOrUpdate(p=> new {p.ArtistId, p.ComicBookId},
                    new ArtistComicBook { ArtistId = 1, ComicBookId = 1},
                    new ArtistComicBook { ArtistId = 1, ComicBookId = 5},
                    new ArtistComicBook { ArtistId = 3, ComicBookId = 2},
                    new ArtistComicBook { ArtistId = 4, ComicBookId = 3},
                    new ArtistComicBook { ArtistId = 5, ComicBookId = 4},
                    new ArtistComicBook { ArtistId = 6, ComicBookId = 7},
                    new ArtistComicBook { ArtistId = 2, ComicBookId = 1},
                    new ArtistComicBook { ArtistId = 7, ComicBookId = 6},
                    new ArtistComicBook { ArtistId = 9, ComicBookId = 5},
                    new ArtistComicBook { ArtistId = 8, ComicBookId = 8},
                    new ArtistComicBook { ArtistId = 2, ComicBookId = 9},
                    new ArtistComicBook { ArtistId = 9, ComicBookId = 11},
                    new ArtistComicBook { ArtistId = 3, ComicBookId = 9},
                    new ArtistComicBook { ArtistId = 1, ComicBookId = 7},
                    new ArtistComicBook { ArtistId = 4, ComicBookId = 5}

                    
                    );
            }
        }
    }
    }

